#include "ThreadPool.hpp"
#include "Thread.hpp"
#include "Task.hpp"

#include <unistd.h>
#include <memory>
using std::cout;
using std::endl;

int main()
{
    //std::unique_ptr<ThreadPool<Task>> tp(new ThreadPool<Task>());
    //tp->run();


    // srand((size_t)time(0) ^ 0x22116652);
    // int x, y;
    // char op;
    // while (true)
    // {
    //     x = rand() % 10 + 1;
    //     y = rand() % 5 + 1;
    //     op = oper[rand() % oper.size()];
    //     Task t(x, y, op, mymath);
    //     tp->push(t);
    //     sleep(1);
    // }
    
    cout<<ThreadPool<Task>::GetInstance()<<endl;
    cout<<ThreadPool<Task>::GetInstance()<<endl;
    cout<<ThreadPool<Task>::GetInstance()<<endl;
    cout<<ThreadPool<Task>::GetInstance()<<endl;

    ThreadPool<Task>::GetInstance()->run();
    srand((size_t)time(0) ^ 0x22116652);
    int x, y;
    char op;
    while (true)
    {
        x = rand() % 10 + 1;
        y = rand() % 5 + 1;
        op = oper[rand() % oper.size()];
        Task t(x, y, op, mymath);
        ThreadPool<Task>::GetInstance()->push(t);
        sleep(1);
    }
    return 0;
}

// void* run(void* args)
// {
//     std::string name=static_cast<const char*>(args);
//     while (true)
//     {
//         cout<<name<<endl;
//         sleep(1);
//     }
//     return nullptr;
// }

// int  main()
// {
//     ThreadCat::Thread t1(run,(void*)"thread 1 run");
//     ThreadCat::Thread t2(run,(void*)"thread 2 run");

//     t1.start();
//     t2.start();

//     t1.join();
//     t2.join();
// }
